package com.o2o.demo.service.impl;

/*
 * cxf ws developer help
 * http://cxf.apache.org/docs/jax-ws-configuration.html
*/
import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.o2o.demo.service.UserService2;
import com.o2o.demo.service.Users;
import com.o2o.demo.utils.JSONUtils;

@Service("userServiceImpl2")
@Transactional
public class UserServiceImpl2 implements UserService2 {

	public List<Users> getAll() {
		List<Users> userList = new ArrayList<Users>();
		Users user1 = new Users();
		user1.setPassword("123456");
		user1.setType(1);
		user1.setUserName("user1");
		Users user2 = new Users();
		user2.setPassword("123456");
		user2.setType(1);
		user2.setUserName("user2");
		Users user3 = new Users();
		user3.setPassword("123456");
		user3.setType(2);
		user3.setUserName("user3");
		userList.add(user1);
		userList.add(user2);
		userList.add(user3);
		return userList;
	}

	public String getAllToJson() {
		List<Users> userList = new ArrayList<Users>();
		Users user1 = new Users();
		user1.setPassword("123456");
		user1.setType(1);
		user1.setUserName("user1");
		Users user2 = new Users();
		user2.setPassword("123456");
		user2.setType(1);
		user2.setUserName("user2");
		Users user3 = new Users();
		user3.setPassword("123456");
		user3.setType(2);
		user3.setUserName("user3");
		userList.add(user1);
		userList.add(user2);
		userList.add(user3);
		return JSONUtils.toJSONString(userList);
	}

	public String getUserByType(int type) {
		Users user1 = new Users();
		user1.setPassword("123456");
		user1.setType(1);
		user1.setUserName("user1");
		Users user2 = new Users();
		user2.setPassword("123456");
		user2.setType(1);
		user2.setUserName("user2");
		return type==1?JSONUtils.toJSONString(user1):JSONUtils.toJSONString(user2);
	}
	
	public String getUserByName(String name,String password) {
		Users user1 = new Users();
		user1.setPassword("123456");
		user1.setType(1);
		user1.setUserName("user1");
		Users user2 = new Users();
		user2.setPassword("123456");
		user2.setType(1);
		user2.setUserName("user2");
		return name=="user1"?JSONUtils.toJSONString(user1):JSONUtils.toJSONString(user2);
	}
	
}
